#include <QApplication>
#include <QQmlApplicationEngine>

#include <QtQml>
#include <QIcon>
#include "mainwindow.h"
#include "playercontrols.h"
#include "network.h"

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    QIcon icon(":images/qt-logo.ico");
    app.setWindowIcon(icon);

    QMediaPlaylist *playList = new QMediaPlaylist();

    playList->setPlaybackMode(QMediaPlaylist::Loop);
    PlayListModel model;
    model.setPlayList(playList);

    MainWindow *mainWindow = new MainWindow();

    QMediaPlayer *player = new QMediaPlayer(mainWindow,QMediaPlayer::StreamPlayback);

    player->setPlaylist(playList);

    mainWindow->setModel(&model);
    mainWindow->setPlayer(player);

    PlayerControls *playerControls = new PlayerControls();
    playerControls->setPlayer(player);

    QQmlApplicationEngine engine;

    engine.rootContext()->setContextProperty("myModel",&model);
    engine.rootContext()->setContextProperty("player",player);
    engine.rootContext()->setContextProperty("playerControlsModel",playerControls);
    engine.rootContext()->setContextProperty("windowModel",mainWindow);
    engine.load(QUrl(QStringLiteral("qrc:/main.qml")));

    return app.exec();
}
